package com.bandaotixi.cashier.api.core.mybatis;

import com.bandaotixi.cashier.api.common.model.KeyValue;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface CommonQueryMapper {

    @SelectProvider(type = CommonQueryProvider.class, method = "relationalQuery")
    List<KeyValue<Long, Long>> relational(@Param("table") String table,
                                          @Param("keyColumn") String keyColumn,
                                          @Param("valueColumn") String valueColumn,
                                          @Param("where") Map<String,Object> where);

    @InsertProvider(type = CommonQueryProvider.class, method = "buildUpsert")
    int upsert(@Param("table") String table,
               @Param("data") Map<String, Object> data);

    @InsertProvider(type = CommonQueryProvider.class, method = "buildBatchUpsert")
    int batchUpsert(@Param("table") String table,
                    @Param("dataList") List<Map<String, Object>> dataList);

    // 删除
    @UpdateProvider(type = CommonQueryProvider.class, method = "buildDelete")
    int delete(@Param("table") String table,
               @Param("where") Map<String, Object> where);
}
